<template>
	<view class="content">
		<button class="size" @tap="startRecognize">启动语音识别</button>
		<view>{{text}}</view>
		<button class="size" @tap="stopRecognize">停止语音识别</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				text: null
			}
		},
		methods: {
			startRecognize() {
				let that = this;
				var options = {};
				options.engine = 'iFly';
				that.text = "";
				console.log("开始语音识别：");
				plus.speech.startRecognize(options, function(s) {
					that.text += s;
				}, function(e) {
					console.log("语音识别失败：" + e.message);
				});

			},
			stopRecognize() {
				plus.speech.stopRecognize();
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.size {
		margin: 30rpx 0;
	}
</style>
